package com.itheima03;

import java.lang.reflect.Array;
import java.util.Arrays;

/**
 * @author Xiao
 * @date 2021/7/20
 */
public class ArrayDemo04 {
    /**
     * 冒泡排序
     */
    public static void main(String[] args) {
        int[] arr = {1, 3, 5, 7, 9, 2, 4, 6, 8};
        for (int j = 0; j < arr.length - 1; j++) {
            for (int i = 0; i < arr.length - 1; i++) {
                if (arr[i] > arr[i + 1]) {
                    int temp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = temp;
                }
            }
        }
        for (int i : arr) {
            System.out.print(i + "  ");
        }
        System.out.println();
        System.out.println("---------");
        Arrays.sort(arr);
        String s = Arrays.toString(arr);
        System.out.println(s);
    }
}
